package com.tuosha.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.tuosha.dao.XinYongKasDao;
import com.tuosha.model.XinYongKasEntity;
import com.tuosha.service.XinYongKasService;



@Service("xinYongKasServiceImpl")
public class XinYongKasServiceImpl implements XinYongKasService {
	@Autowired
	private XinYongKasDao xinYongKasDao;


	@Override
	public XinYongKasEntity queryObject(Integer id){
		return xinYongKasDao.queryObject(id);
	}
	
	@Override
	public List<XinYongKasEntity> queryList(Map<String, Object> map){
		return xinYongKasDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return xinYongKasDao.queryTotal(map);
	}
	
	@Override
	public void save(XinYongKasEntity xinYongKas){
		Date date=new Date();
		xinYongKas.setCreatedAt(date);
		xinYongKasDao.save(xinYongKas);
	}
	
	@Override
	public int update(XinYongKasEntity xinYongKas){
		Date date=new Date();
		xinYongKas.setUpdatedAt(date);
		return xinYongKasDao.update(xinYongKas);
	}
	
	@Override
	public int delete(Integer id){
		return xinYongKasDao.delete(id);
	}
	
	@Override
	public int deleteBatch(Integer[] ids){
		return xinYongKasDao.deleteBatch(ids);
	}

	public int delById(Integer id){
		Date date=new Date();
		XinYongKasEntity xinYongKas= new XinYongKasEntity();
		xinYongKas.setId(id);
		xinYongKas.setDeletedAt(date);
		return xinYongKasDao.update(xinYongKas);
	}

	public int delPatch(String  xykstr){
		String[] strs = xykstr.split(",");
		if(strs!=null&&strs.length>0){
			for (String str : strs) {
				delById(Integer.parseInt(str));
			}
		}
		return 0;
	}

	public XinYongKasEntity queryName(String name){
		return xinYongKasDao.queryName(name);
	}


}
